package com.yk.filedownload.util.logger;

import org.apache.log4j.Logger;

import java.io.FileNotFoundException;
import java.io.IOException;

/**
 * Project Name:cykfiledownload
 * File Name:ExceptionCatcher
 * Package Name:com.yk.filedownload.util.logger
 * Date:2017\12\15 0015
 * Author:dengtianjia
 * Description:
 * Copyright (c) 2017, 重庆云凯科技有限公司 All Rights Reserved.
 */
public class ExceptionCatcher {

    /**
     * 多线程中的异常捕捉
     * @param e
     * @param logger
     * @param object
     */
    public void catchException(Exception e , Logger logger , Object object){
        if(e instanceof IOException)
            logger.error(object.getClass().getSimpleName() +"执行时发生io异常");
        if(e instanceof InterruptedException)
            logger.error(object.getClass().getSimpleName()+"异步方法执行异常");
        if(e instanceof FileNotFoundException)
            logger.error(object.getClass().getSimpleName()+"加载文件时没有找到");
        if (e instanceof NullPointerException)
            logger.error(object.getClass().getSimpleName()+"发生空值异常");
    }



}
